class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target) {
        // 前后指针
        int n = price.size();
        int left = 0, right = n - 1;

        // 利用单调性
        for( ; price[left] + price[right] != target; )
        {
            if(price[left] + price[right] < target)
                left++;
            else if(price[left] + price[right] > target)
                right--;
            else
                break;
        }

        // 定义一个int数组sum，插入两个值
        vector<int> sum;
        sum.push_back(price[left]);
        sum.push_back(price[right]);

        return sum;
    }
};